{% load i18n %}
{% load admin_list staticfiles filer_tags %}
{% load url from suit_compat %}

<div id="toolbartable" class="results">
      <table id="result_list" class="table table-striped table-bordered table-hover table-condensed">
        <thead>
            <tr class="{% cycle 'row1' 'row2' as rowcolors %}">
                <th{% if is_popup %} style="width: 3em;"{% else %} class="action-checkbox-column"{% endif %}>{% if paginator.count and not select_folder and not is_popup %}<input type="checkbox" id="action-toggle" />{% endif %}</th>
                <!-- THUMB -->
                <th class="thumbHeader">&nbsp;</th>
                <!-- FILENAME / FOLDERNAME / DIMENSIONS / OWNER -->
                <th>{% trans 'Name' %}</th>
                <th style="width: 2.5em;"></th>
            </tr>
        </thead>
        <tbody>
        {% for item, item_perms in paginated_items.object_list %}
            {% if item.file_type == 'Folder' or item.file_type == 'DummyFolder' %}{% with item as subfolder%}
            <tr class="{% cycle rowcolors %}">
                <td>{% if select_folder and item.file_type == 'Folder' %}<a class="insertlink insertlinkButton btn btn-info btn-small" href="" onclick="opener.dismissRelatedFolderLookupPopup(window, {{ subfolder.id }}, '{{ subfolder.pretty_logical_path }}'); return false;" ><i class="icon-ok-sign icon-white"></i></a>{% else %}{% if action_form and item.pk and not is_popup %}<input type="checkbox" class="action-select" value="folder-{{ item.pk }}" name="_selected_action" />{% endif %}{% endif %}</td>
                <!-- DirIcon -->
                <td><a href="{{ subfolder.get_admin_directory_listing_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with subfolder.name as item_label %}Change '{{ item_label }}' folder details{% endblocktrans %}"><img src="{{ subfolder.icons.48 }}" alt="{% trans "Folder Icon" %}" /></a></td>
                <!-- Directory details -->
                <td>
                    {% if item.file_type == 'Folder' and item_perms.change %}
                        <a style="display: block; float: right;" class="changelink" href="{{ subfolder.get_admin_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with subfolder.name as item_label %}Change '{{ item_label }}' folder details{% endblocktrans %}">{% trans "Change" %}</a>
                    {% endif %}
                    <div><b><a href="{{ subfolder.get_admin_directory_listing_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with subfolder.name as item_label %}Change '{{ item_label }}' folder details{% endblocktrans %}">{{ subfolder.name }}</a></b></div>
                    <div class="file-info muted">{% if not subfolder.is_root %}<span class="tiny file-size">{% blocktrans count subfolder.children_count as counter %}1 folder{% plural %}{{ counter }} folders{% endblocktrans %}, {% blocktrans count subfolder.file_count as counter %}1 file{% plural %}{{ counter }} files{% endblocktrans %}</span><br>{% endif %}{% trans "Owner" %}: {{ subfolder.owner|default:"n/a" }}</div>
                </td>
                <td></td>
            </tr>
            {% endwith %}{% endif %}
            {% if item.file_type == 'File' or item.file_type == 'Image' %}{% with item as file %}
            <tr class="{% cycle rowcolors %}">
                <td>{% if is_popup and not select_folder %}<a class="insertlink insertlinkButton btn btn-info btn-small" href="" onclick="opener.dismissRelatedImageLookupPopup(window, {{ file.id }}, '{{ file.icons.48|escapejs }}', '{{ file.label|escapejs }}'); return false;" title="{% trans "Select this file" %}"><i class="icon-ok-sign icon-white"></i></a>{% else %}{% if action_form and not is_popup %}<input type="checkbox" class="action-select" value="file-{{ item.pk }}" name="_selected_action" />{% endif %}{% endif %}</td>
                <!-- FileIcon -->
                <td>{% if item_perms.change %}<a href="{{ file.get_admin_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">{% endif %}<img src="{% if file.icons.48 %}{{ file.icons.48 }}{% else %}{% static 'filer/icons/missingfile_48x48.png' %}{% endif %}" alt="{{ file.default_alt_text }}" />{% if item_perms.change %}</a>{% endif %}</td>
                <!-- Filename/Dimensions -->
                <td>
                    <a style="display: block; float: right;margin-left: 10px;" class="deletelink text-error" href="{% url 'admin:filer_file_delete' file.pk %}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with file.label as item_label %}Delete '{{ item_label }}'{% endblocktrans %}">{% trans "Delete" %}</a>
                    <a style="display: block; float: right;" class="changelink" href="{{ file.get_admin_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">{% trans "Change" %}</a>
                    <div><b><a href="{{ file.get_admin_url_path }}{% if is_popup %}?_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}" title="{% blocktrans with file.label as item_label %}Change '{{ item_label }}' details{% endblocktrans %}">{{ file.label }}</a></b></div>
                    <div class="file-info muted"><span class="file-size">{{ file.size|filesizeformat }}{% ifequal file.file_type "Image" %}, {{ file.width }}x{{ file.height }} px{% endifequal %}</span><br>{% trans "Owner" %}: {{ file.owner|default:"n/a" }}{% if enable_permissions %}. {% trans "Permissions" %}: {% if file.is_public %}{% trans "disabled" %}{% else %}{% trans "enabled" %}{% endif %}{% endif %}</div>
                    {# {% if file.has_all_mandatory_data %}<div><img alt="0" src="{% admin_icon_base %}img/admin/icon-yes.gif" /> {% trans "has all mandatory metadata" %}</div>{% else %}<div><img alt="1" src="{% admin_icon_base %}img/admin/icon-no.gif"/> {% trans "missing metadata!" %}</div>{% endif %} #}
                </td>
                <td style="text-align: right;">
                    <button type="submit" name="move-to-clipboard-{{ file.id }}" title="{% trans "Move to clipboard" %}"{% if file in clipboard_files or not item_perms.change %} style="color: gray;" disabled="disabled"{% endif %} class="btn btn-small"><i class="icon-arrow-right"></i></button>
                </td>
            </tr>
            {% endwith %}{% endif %}
        {% endfor %}
        {% if not folder.is_root %}{% ifequal folder.item_count 0 %}
        <tr class="{% cycle rowcolors %}">
                <!-- FileIcon -->
                <td colspan="5" class="row1" style="text-align: center;vertical-align: middle;height:128px;color: gray;">{% trans "there are no files or subfolders" %}</td>
            </tr>
        {% endifequal %}{% endif %}
        </tbody>
    </table>
    <div class="pagination-block">
        {% if paginated_items.has_previous %}
            <a href="?page={{ paginated_items.previous_page_number }}{% if q %}&q={{ q }}{% endif %}{% if is_popup %}&_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}">{% trans "previous"|capfirst %}</a>
        {% endif %}

        <span class="this-page muted">
            {% blocktrans with paginated_items.number as number and paginated_items.paginator.num_pages as num_pages %}
            Page {{ number }} of {{ num_pages }}
            {% endblocktrans %}
        </span>

        {% if paginated_items.has_next %}
            <a href="?page={{ paginated_items.next_page_number }}{% if q %}&q={{ q }}{% endif %}{% if is_popup %}&_popup=1{% if select_folder %}&select_folder=1{% endif %}{% endif %}">{% trans "next"|capfirst %}</a>
        {% endif %}
    </div>
</div>
